import time,os
import Settings

class Log():

	def rwitelog(self, info, exit=False):
		filename = self.getlogName()
		info = info + " 时间：%s" % time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
		with open(filename, 'a+', encoding='utf8') as file:
			file.write(info+'\n')
		print(info)
		if exit is True:
			with open(filename, 'a+', encoding='utf8') as file:
				file.write('操作结束'+'\n')
			print('操作结束')
			exit()

	def getlogName(self):
		filename = Settings.LogDir+time.strftime("%Y-%m-%d", time.localtime())+'.log'
		if os.path.exists(Settings.LogDir) is False:
			os.mkdir(Settings.LogDir)
		return filename

		